package com.azzcs.juc.aqs;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @Author: wzg
 * @Date: 2021/6/18 下午3:14
 */
public class Lock {
    private static ReentrantLock lock = new ReentrantLock();
    public static void main(String[] args) {
        for (int i = 1; i < 6; i++) {
            new Thread(()->{
                lock.lock();
                try{
                    TimeUnit.SECONDS.sleep(10);
                }catch (Exception e){
                    e.printStackTrace();
                }finally {
                    lock.unlock();
                }
            }).start();
        }
    }
}
